﻿namespace FFF.Test.Application.Framework
{
    using System;
    using System.Collections.Generic;
    using System.Reflection;
    using System.Text;
    using Abp.AutoMapper;
    using Abp.Modules;
    using Abp.Reflection.Extensions;
    using Abp.Threading.BackgroundWorkers;
    using FFF.Test.Application.Framework.Providers;
    using FFF.Test.DataAccess.Framework;
    using FFF.Test.Util.Consts;

    /// <summary>
    /// 应用层模块
    /// </summary>
    [DependsOn(
         typeof(YdmAbpDataAccessModule))]
    public class YudmAbpApplication99FrameWorkModule : AbpModule
    {
        /// <summary>
        /// 初始化应用层配置
        /// </summary>
        public override void PreInitialize()
        {
            // 添加权限的注册
            this.Configuration.Authorization.Providers.Add<YdmAbpAuthorizationProvider>();

            // 站点缓存
            this.Configuration.Caching.Configure(CacheAppConsts.WebSiteCache, cache =>
            {
                cache.DefaultSlidingExpireTime = TimeSpan.FromDays(365);
            });

            // 用户缓存
            this.Configuration.Caching.Configure(CacheAppConsts.UserStoreCache, cache =>
            {
                cache.DefaultSlidingExpireTime = TimeSpan.FromHours(2);
            });
        }

        /// <summary>
        /// 依赖注入初始化
        /// </summary>
        public override void Initialize()
        {
            Assembly thisAssembly = typeof(YudmAbpApplication99FrameWorkModule).GetAssembly();

            this.IocManager.RegisterAssemblyByConvention(thisAssembly);
        }
    }
}